<%--
 *  File:    MonthPlanManagementMain.jsp
 *  @Author: DC
 *  Date:    2011/09/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page import="java.text.*" %>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>



<% //--------------------------------------  setting logger --%>
<%
  Category cat = Category.getInstance("jsp.MonthPlanManagementMain");
  //init param
  String strModuleName = "COM";
  String privilegeCode = "FP0910";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<iframe name="reloadHandler" style="display:none" ></iframe>
<html>
<head>
<PageFlow:CheckPageFlow pageName="p_monthplanmanagentmain"/>
<%--@ include file="/inc/CatchError.inc" --%>
<%
	//params
     String viewflag = "";

     if(pageContext.getAttribute("viewflag") != null&&((String)pageContext.getAttribute("viewflag")).equals("view")) {

           viewflag = "view";
     }


    String strIsDefault = null;
	String paraIsDefault = "";
	String isTdNeed = "td-text";
	if("Y".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
  String isNew = "";
  if("Y".equals(request.getParameter("isNew"))) {
		isNew = "Y";
	}else if ("N".equals(request.getParameter("isNew"))) {
		isNew = "N";
	}else  {
		isNew = null;
	}
  //params end
  
  HashMap monthplaninfo = null;
  String valuemonthplanid = null;
  String dateOpt = null;
  monthplaninfo = (HashMap)pageContext.getAttribute("monthplaninfo");
	  if(monthplaninfo != null&&monthplaninfo.size()!=0) {
  		if(isNew!=null && isNew.equals("Y")){
  			valuemonthplanid = JspHelper.filterNull( monthplaninfo.get("monthplanid") ).toString();
	  	}
		dateOpt = JspHelper.filterNull( monthplaninfo.get("createdate") ).toString();
      }else {
    	  monthplaninfo = new HashMap();
    	  monthplaninfo.put("status",new Integer(10));
    	  monthplaninfo.put("createdate",new java.sql.Date(System.currentTimeMillis()));
		  pageContext.setAttribute("monthplaninfo",monthplaninfo);
		  valuemonthplanid = "";
		  monthplaninfo = (HashMap)pageContext.getAttribute("monthplaninfo");
      }
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
  
  
	String dateFormat = (String)session.getAttribute("dateformat");
	if(dateFormat==null)dateFormat = "yyyy-MM-dd";
  
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<%@ include file ="/inc/NewCalendar.inc" %>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<script language="JavaScript">





function page_save()
{	
	if(!checkForm(cform))   return;
	emptyToNull(cform);


	var frm = document.cform;

	if(isEmpty(frm.dpcyclemainid.value)){

		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_MCycle",false)) %>");
		return;
		}
	frm.actionname.value = "save";
	frm.target = "_parent";
	frm.submit();
}
function page_submit()
{
	if(!checkForm(cform))   return;

   if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )  return;
	var frm = document.cform;
	frm.actionname.value = "submit";
	frm.target = "_parent";
	frm.submit();
}
function page_back()
{  
  parent.location.href = "MonthPlanManagement.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault )%>";
}

function  reload_parentemp(){

	 if( isEmpty(document.cform.dpcyclemainid.value))
	   return;
	 var  datahandler = new  DataHandler() ;

	 datahandler.add_params("dpcyclemainid" , document.cform.zmylagreementconfigid.value,"Integer");
	datahandler.getResultFromHashMap("dpcyclemaininfo" ,"dpcyclemainname" ,"document.cform.dpcyclemainname");

	 datahandler.add_job("j_initdpcycleditmain") ;
	 datahandler.runDataHandler ();
	}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
   <form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
      <input type="hidden" name="pagename" value="p_monthplanmanagentmain">
      <input type="hidden" name="actionname">
	      <custom:hidden name="userinfo" property="orgid" scope="session"  />
      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
	  <input type="hidden" name="isNew" value="<%= isNew %>">
	  
	  	 
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
      <custom:hidden name ="monthplaninfo" property="monthplanid" />
      



    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
            
           
           <tr>
            <td colspan="4" class="deepblue-left" height="22"> <img src="<%=contextPath %>/images/<%= strLanguageCode %>/quote.gif">
            &nbsp;</td>
          </tr>
         <%--	if(viewflag.equals("view")){--%>
          <tr>

          <td class="td-text" width="110" ><%= label.getLabelName("L_plane_code")+ label.getLabelName("L_Colon")%></td>
          	<td>

                  &nbsp;<custom:write  name="monthplaninfo" property="monthplancode" />

               </td>
             <td class="td-text" width="110" ><%= label.getLabelName("L_PlanName") + label.getLabelName("L_Colon") %></td>
            <td>
				&nbsp;<custom:write  name="monthplaninfo" property="monthplanname"  />
           	</td>
          </tr>
          
          <tr>
           <td  class="td-text" width="110" ><%= label.getLabelName("L_Year1") + label.getLabelName("L_Colon") %></td>
           	<td>
           	&nbsp;<custom:write property="year"  name="monthplaninfo"/>
           	</td>
           	<td  class="td-text" width="110" ><%= label.getLabelName("L_Month") + label.getLabelName("L_Colon") %></td>
           	<td>
           	&nbsp;<custom:write property="month" name="monthplaninfo" />
           	</td>
           	</tr>
           	
           <tr>
           <td  class="td-text" width="110" ><%= label.getLabelName("L_PlanType	") + label.getLabelName("L_Colon") %></td>
           	<td>
              &nbsp;
              
              <!--<custom:select disabled="true" name="yearplaninfo" property="plantypeid" optionsName="plantypesummary" command="notnull" label="L_PlanType" optionValueKey="plantypeid" optionInnerTextKey="plantypename"  defaultValue="--------------" defaultValueCost=""/>-->
           	
           		<custom:write property="plantypename" name="monthplaninfo" />
           	</td>
           	
           	<td  class="td-text" width="110" ><%=label.getLabelName("L_MCycle") + label.getLabelName("L_Colon") %></td>

           	<td>
                &nbsp;

               <!--     <custom:select disabled="true" name="yearplaninfo" property="dpcyclemainid" optionsName="dpcyclemainsummary" command="notnull" label="L_MCycle" optionValueKey="dpcyclemainid" optionInnerTextKey="dpcyclemainname"  defaultValue="--------------" defaultValueCost=""/> -->  
            	
            	<custom:write property="dpcyclemainname" name="monthplaninfo" />
            </td>
           	</tr>
           	<tr>
            <td class="td-text" width="110" ><%= label.getLabelName("L_SalesKPI") + label.getLabelName("L_Colon") %></td>
            <td>&nbsp;<custom:write property="totalamount" name="monthplaninfo"  /></td>
            <td class="td-text" width="110" ><%= label.getLabelName("L_Balance") + label.getLabelName("L_Colon") %></td>
            <td>&nbsp;<custom:write property="balance" name="monthplaninfo"  /></td>
           	</tr>
           	<tr>
			<td class="td-text" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td> &nbsp;<custom:write  name="monthplaninfo" property="username"   /> </td>
            
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td colspan="3">

             &nbsp;  <custom:write property="statusname"  name="monthplaninfo"  />
            </td>
          </tr>
          
          <tr>
            <td class="td-text" width="110" ><%= label.getLabelName("L_CreateTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				<custom:write name="monthplaninfo" property="createdate" dataType="date" dataFormatName="dateformat"/>
           	</td>
           	
           	<td class="td-text" width="110" ><%= label.getLabelName("L_TurnoverTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				&nbsp;<custom:write name="monthplaninfo" property="datelastupdated" dataType="date"/>
           	</td>
          </tr>
          <tr>
          <td class="td-text"width="110" ><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" ><custom:textarea readonly="true" name="monthplaninfo" property="comments" cols="120" rows="4" />
               </td>
           </tr>
<%--}else{ %>
           
      <tr>
       	   <td class="need" width="110" ><%= label.getLabelName("L_plane_code")+ label.getLabelName("L_Colon") %></td>
          	<td> 
                  &nbsp;<custom:write   name="yearplaninfo" property="yearplancode"   />
               </td>
             <td class="need" width="110" ><%= label.getLabelName("L_PlanName") + label.getLabelName("L_Colon") %></td>
            <td>
			<custom:text  name="yearplaninfo" property="yearplanname"   command="notnull" label="L_PlanName" />
           	</td>
          </tr>
          
         <tr>
           <td  class="need" width="110" ><%= label.getLabelName("L_Year1") + label.getLabelName("L_Colon") %></td>
           	<td>
           	<custom:text property="year" name="yearplaninfo" command="notnull"  dataType="integer" command="notnull" label="L_Year1" maxlength="4" maxValue="2099"/>
           	</td>
           	
           	<td  class="td-text" width="110" ><%= label.getLabelName("L_Month") + label.getLabelName("L_Colon") %></td>
           	<td>
           	<custom:text property="month" name="yearplaninfo" dataType="integer"  label="L_Month" maxlength="2" maxValue="12"/>
           	</td>
           	</tr>
           	
           <tr>
           <td  class="need" width="110" ><%= label.getLabelName("L_PlanType	") + label.getLabelName("L_Colon") %></td>
           	<td>
             <%if(yearplaninfo.get("yearplanid")!=null){%>
                <custom:select disabled="true" changedName="readplantypeid" name="plantypeinfo" property="plantypeid" optionsName="plantypesummary"
                                   command="notnull" label="L_PlanType" optionValueKey="plantypeid"
                                   optionInnerTextKey="plantypename"  defaultValue="--------------" defaultValueCost=""/>
                   <custom:hidden property="plantypeid"  name="plantypeinfo"   />

 
                <%}else{%>

           	 <custom:select name="yearplaninfo" property="plantypeid" optionsName="plantypesummary"
                                   command="notnull" label="L_PlanType" optionValueKey="plantypeid"
                                   optionInnerTextKey="plantypename"  defaultValue="--------------" defaultValueCost=""/>
                        
           	     <%}%>
           	</td>
           	
           	<td  class="need" width="110" ><%=label.getLabelName("L_MCycle") + label.getLabelName("L_Colon") %></td>

           	<td>
           <%if(yearplaninfo.get("yearplanid")!=null){%>
                <custom:select disabled="true" changedName="readdpcyclemainid" name="dpcyclemaininfo" property="dpcyclemainid" optionsName="dpcyclemainsummary"
                                   command="notnull" label="L_MCycle" optionValueKey="dpcyclemainid"
                                   optionInnerTextKey="dpcyclemainname"  defaultValue="--------------" defaultValueCost=""/>
                   <custom:hidden property="dpcyclemainid"  name="dpcyclemaininfo"   />

 
                <%}else{%>
                      <custom:select name="yearplaninfo" property="dpcyclemainid" optionsName="dpcyclemainsummary"
                                   command="notnull" label="L_MCycle" optionValueKey="dpcyclemainid"
                                   optionInnerTextKey="dpcyclemainname"  defaultValue="--------------" defaultValueCost=""/>
                                   
               <%}%>

            </td>
           	</tr>
           	<tr>
            <td class="need" width="110" ><%= label.getLabelName("L_SalesKPI") + label.getLabelName("L_Colon") %></td>
             <%if(yearplaninfo.get("yearplanid")!=null){%>
            <td>&nbsp;<custom:write property="totalamount" name="yearplaninfo"   /></td>
             <%}else{%>
             <td>&nbsp;<custom:text property="totalamount" name="yearplaninfo" dataType="number"  label="L_SalesKPI" command="notnull,notnegative" /></td>
             <%}%>
            <td class="td-text" width="110" ><%= label.getLabelName("L_Balance") + label.getLabelName("L_Colon") %></td>
            <td>&nbsp;<custom:write property="balance" name="yearplaninfo"  /></td>
           	</tr>
           	<tr>
            <td class="td-text" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td>
                <%if(yearplaninfo.get("yearplanid")!=null){%>
                 <oval:hidden name="yearplaninfo" property="maker"  />
                 <custom:write  name="yearplaninfo" property="username"   />

                <%}else{%>
                    <oval:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
                    <oval:write name="userinfo" property="username" scope="session"   />
               <%}%>
            </td>
            
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td colspan="3">

               <custom:selectdic property="status" dictType="Status" name="yearplaninfo" valueCriteria="10" defaultValueCost="" label="L_Status" />
            </td>
          </tr>
          <tr>
            <td class="td-text" width="110" ><%= label.getLabelName("L_CreateTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				<custom:write name="yearplaninfo" property="createdate" dataType="date" dataFormatName="dateformat"/>
           	</td>
           	
           	<td class="td-text" width="110" ><%= label.getLabelName("L_TurnoverTime") + label.getLabelName("L_Colon") %></td>
           	<td>
				&nbsp;<custom:write name="yearplaninfo" property="datelastupdated" dataType="date"/>
           	</td>
          </tr>
          <tr>
          <td class="td-text"width="110" ><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" ><custom:textarea readonly="true" name="yearplaninfo" property="comments" cols="120" rows="4" />
               </td>

          </tr>
   <%}--%>        
        </table>
      </td>
    </tr>
    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
    <td height="49" class="td_center">
	<%--if(!viewflag.equals("view")){%>
        <a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="back.gif" border="0" style="width:60" /></a>
    <%}--%>
        <a onclick="javascript:page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>


    </td>
    </tr>
</form>
</table>
<script language="JavaScript" src="../../js/Calendar.js" ></script>
<%@include file="/inc/AlertError.inc"%>
</body>
</html>


           		